{% extends 'base.html' %}

{% block title %}资产报废 - 固定资产管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <h2>资产报废</h2>

        <div class="card mb-3">
            <div class="card-header">
                <h5>{{ asset.name }}</h5>
            </div>
            <div class="card-body">
                <p><strong>资产编号:</strong> {{ asset.asset_number }}</p>
                <p><strong>当前状态:</strong>
                    {% if asset.status == 'idle' %}<span class="badge bg-secondary">闲置</span>
                    {% elif asset.status == 'in_use' %}<span class="badge bg-success">在用</span>
                    {% elif asset.status == 'maintenance' %}<span class="badge bg-warning">维修中</span>
                    {% elif asset.status == 'scrapped' %}<span class="badge bg-danger">已报废</span>
                    {% endif %}
                </p>
                <p><strong>所属部门:</strong> {{ asset.department.name|default:'-' }}</p>
                <p><strong>使用人:</strong> {% if asset.user %}{{ asset.user.username }}{% else %}-{% endif %}</p>
            </div>
        </div>

        <div class="alert alert-danger">
            <p><strong>警告:</strong> 此操作将把资产状态设置为"已报废"，且不可逆。请确认是否要报废此资产？</p>
        </div>

        <form method="post">
            {% csrf_token %}

            <div class="mb-3">
                <label for="description" class="form-label">报废原因 *</label>
                <textarea class="form-control" id="description" name="description" rows="3" required></textarea>
            </div>

            <div class="mb-3">
                <button type="submit" class="btn btn-danger">确认报废</button>
                <a href="{% url 'assets:asset_detail' asset.pk %}" class="btn btn-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}